//
//  TViewController.m
//  肿瘤
//
//  Created by 无梦生 on 16/9/13.
//  Copyright © 2016年 Sampson. All rights reserved.
//

#import "ChooseViewController.h"
#import <AFNetworking.h>
#import <SVProgressHUD.h>
@interface ChooseViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)NSArray * muArray;

@property (nonatomic,weak)UITableView * tableView;

@property (nonatomic,assign)NSInteger index;
@end

@implementation ChooseViewController

-(NSArray *)muArray
{
    if (!_muArray) {
        _muArray = @[@"药物治疗",@"植物治疗",@"其他治疗"];
    }
    return _muArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.title = @"选择";
    
    [self creatTableView];
}

-(void)creatTableView
{
    UITableView * tableView  = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    
    tableView.dataSource = self;
    tableView.delegate = self;
    self.tableView = tableView;
    [self.view addSubview:tableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    
    self.index = indexPath.row;
    cell.textLabel.text = self.muArray[self.index];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString * str  = self.muArray[indexPath.row];
    if (self.block) {
        self.block(str);
    }
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)returnText:(void(^)(NSString*str))block {
    self.block = block;
}


@end
